import time
"""
竞品信息
"""
def get_jingpin_info(mongo_instance, soup, cid, company):
    print('start 竞品信息*******')
    try:
        for tr in soup.find('div', id='_container_jingpin').find('tbody').find_all('tr') if soup.find('div',
                                                                                                      id='_container_jingpin') else []:
            item = {}
            tds = tr.find_all('td')

            if len(tds) > 6:
                if tds[1].find('tbody'):
                    item['name'] = tds[1].find('tbody').find_all('td')[1].text
                    item['icon'] = tds[1].find('tbody').find_all('td')[0].find('img')['src']
                    item['area'] = tds[4].text
                    item['lunci'] = tds[5].text
                    item['hangye'] = tds[6].text
                    item['yewu'] = tds[7].text
                    item['date'] = tds[8].text
                    item['guzhi'] = tds[9].text
                    item['create_at'] = int(time.time())
                    item['update_at'] = item['create_at']
                    item['company'] = company
                    item['company_id'] = cid
                    print(item)
                    mongo_instance.jingpin.update({'company_id': cid}, item, True)

        print('success 竞品信息*******')
    except Exception as e:
        print(e, company)